<?php

class Alcance_Form_Add extends Zend_Form {

    public function init() {


        $this->setName('form_alcance');
        $this->setMethod('post');

        // username
        $title = new Zend_Form_Element_Text('title');
        $title->setLabel('Titulo')
                ->setRequired(true)
                ->addFilter('StripTags')
                ->addFilter('StringTrim')
                ->addFilter('StringToLower')
                ->addValidator('NotEmpty', true, array('messages' => 'Ingrese un titulo'));




        $desc = new Zend_Form_Element_Textarea('description');
        $desc->setLabel('Descripcion')
                ->setRequired(true)
                ->setAttrib('rows', 10)
                ->setAttrib('cols', 50)
                ->addFilter('StripTags')
                ->addFilter('StringTrim')
                ->addValidator('NotEmpty', true, array('messages' => 'Ingrese una descripcion'));



        $dateValidator = new Zend_Validate_Date('dd-mm-yyyy');


        $fechai = new Zend_Form_Element_Hidden('create_date');
        $fechai
                ->setRequired(true)
                ->addFilter('StripTags')
                ->addFilter('StringTrim')
                ->setValue(date("Y-m-d"))
                ->addFilter('StringToLower')
                ->addValidator('NotEmpty', true, array('messages' => 'Ingrese la fecha de creacion'))
                ->addValidator('Date', true, array('messages' => 'Fecha incorrecta'));


        $fechaf = new Zend_Form_Element_Text('end_date');
        $fechaf->setLabel('Fecha Finalizacion')
                ->setRequired(true)
                ->addFilter('StripTags')
                ->addFilter('StringTrim')
                ->addFilter('StringToLower')
                ->addValidator('NotEmpty', true, array('messages' => 'Ingrese la fecha de finalizacion'))
                ->addValidator($dateValidator, true, array('messages' => 'Fecha incorrecta'));





        $fechau = new Zend_Form_Element_Hidden('update_date');
        $fechau
                ->setRequired(false)
                ->addFilter('StripTags')
                ->addFilter('StringTrim')
                ->addFilter('StringToLower')
                ->addValidator('NotEmpty', true, array('messages' => 'error'));


        $del = new Zend_Form_Element_Hidden('delete');
        $del
                ->setRequired(false)
                ->addFilter('StripTags')
                ->addFilter('StringTrim')
                ->addFilter('StringToLower')
                ->addValidator('NotEmpty', true, array('messages' => 'error'));


        $estado = new Zend_Form_Element_Checkbox('status');
        $estado->setLabel('Estado')
                ->setRequired(true)
                ->addFilter('StripTags')
                ->addFilter('StringTrim')
                ->addValidator('NotEmpty', true, array('messages' => 'error'));






        $idorden = new Zend_Form_Element_Select('id_orden');
        $idorden->setLabel("orden")
                ->setRequired(true)
                ->addFilter('StripTags')
                ->addFilter('StringTrim')
                ->addFilter('StringToLower')
                ->addMultiOptions(array(
                    "" => "-- Seleccione --"
                ))
                ->addValidator('NotEmpty', true, array('messages' => 'Ingrese su nombre de usuario'));

        $user_create = new Zend_Form_Element_Hidden('id_user_create');
        $user_create
                ->setRequired(false)
                ->addFilter('StripTags')
                ->addFilter('StringTrim')
                ->addFilter('StringToLower')
                ->addValidator('NotEmpty', true, array('messages' => 'Error'));



        // submit
        $submit = new Zend_Form_Element_Submit('submit');
        $submit->setLabel('Ingresar');
        $fin = new Zend_Form_Element_Submit('finalizar');
        $fin->setLabel('Finalizar');


        // add elements
        $this->addElements(array($title, $desc, $fechaf, $idorden, $estado, $submit, $fin, $linkorden, $user_create, $fechau, $del, $fechai));
    }

}